package com.qxm.consumer;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName: {@link MqttController}
 * @Author: AbelEthan
 * @Email AbelEthan@126.com
 * @Date 2023/7/28 14:42
 * @Describes
 */
@RestController
public class MqttController {

    final private MqttConsumerConfig consumerConfig;
    final private MqttConsumerProperties properties;

    public MqttController(MqttConsumerConfig consumerConfig, MqttConsumerProperties properties) {
        this.consumerConfig = consumerConfig;
        this.properties = properties;
    }

    @PostMapping("/connect")
    public String connect(){
        consumerConfig.connect();
        return properties.getClientId() + "连接到服务器";
    }

    @PostMapping("/disConnect")
    public String disConnect(){
        consumerConfig.disConnect();
        return properties.getClientId() + "与服务器断开链接";
    }
}
